<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
        <title>IBM Rational Test Workbench Mobile Client</title>    
        <link rel="shortcut icon" href="/mobile-client/images/rtwios.png"/>
        <script>
            function load() {
                var winURL = window.location.href;
                var queryStringArray = winURL.split("?");
                var queryParamsCoded = queryStringArray[1].split("&");
                var queryParams = [];

                // get query params
                for (i = 0; i < queryParamsCoded.length; i++) {
                    queryParams[i] = queryParamsCoded[i].split("=")[1];
                }
                var uA = navigator.userAgent;
                var launcher = "";
                var device = "";
                
                if (uA.lastIndexOf("Safari") > 0) {
                    if (uA.lastIndexOf("CriOS") > 0) {
                        launcher = "chromeclient";
                    } 
                    else {
                        launcher = "webclient";
                    }
                }
                
                if (uA.lastIndexOf("iPhone") > 0) {
                   device = "iPhone";
                }
                
                // this is required only for safari on iPhone as workaround
                if (launcher != "chromeclient" && device == "iPhone") {
                    alert(decodeURI(queryParams[0]));
                }
                var action = queryParams[1];                
                var url = null;
                if (action == 'i') {
                    url = 'itms-services://?action=download-manifest&url=';
                    url += queryParams[2];
                }
                
                // native app
                else if (action == 'ri' || // record
                    action == 'pi'|| // playback
                    action == 'ppi') { // passive playback
                        url = 'rmot' + queryParams[2];
                        url += '://' + queryParams[3];
                }
                
                // web app
                else if (action == 'rw' ||
                    action == 'pw'||
                    action == 'ppw') {
                        url = 'rmotibmrtwbrowser';
                        url += '://' + queryParams[2];
                }
                var win = window.open(url, '_self');
            }
        </script>
    </head>
    <body onload="load()">
    </body>
</html>